package reflect;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
//        Class c1 = ArrayList.class;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入类名：");
        String className = scanner.nextLine();
        Class c1 = Class.forName(className);
        String name = c1.getName();
        System.out.println(name);//java.lang.String 包名.类名
        name = c1.getSimpleName();
        System.out.println(name);//String 类名
        Package p = c1.getPackage();
        System.out.println(p);//package java.lang, Java Platform API Specification, version 1.8
        System.out.println(p.getName());//java.lang
        Method[] methods = c1.getMethods();
        for(Method m:methods){
            System.out.println(m.getName());
        }
        System.out.println("共"+methods.length+"种方法");


    }
}
